from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node

def generate_launch_description():
    # 声明参数
    vehicle_id_arg = DeclareLaunchArgument(
        'vehicle_id',
        default_value="2",
        description='Vehicle ID.'
    )
    namesspace_arg = DeclareLaunchArgument(
        'namespace',
        default_value="/drone",
        description='Namespace of the nodes.'
    )

    # 创建节点
    udp_gps_forwarder_node = Node(
        package="udp_gps_forwarder",
        executable="udp_gps_forwarder_node",
        name="udp_gps_forwarder_node0",
        output="screen",
        emulate_tty=True,
        parameters=[
            {"vehicle_id": LaunchConfiguration('vehicle_id')},
            {"namespace": LaunchConfiguration('namespace')},
        ]
    )

    # 创建并返回 LaunchDescription
    return LaunchDescription([
        vehicle_id_arg,
        namesspace_arg,
        udp_gps_forwarder_node
    ])
